<!DOCTYPE html>
<html>
<head>
    <title>登陆</title>
    <link rel="stylesheet" href="__STATIC__/js/layui/css/layui.css">
    <style>
        table th, table td{text-align: center;}
        .ml-10 { margin-left: 10px; }
		.layui-icon{font-size: 14px !important;}
		.layui-form-label{ width: auto;}
		.layui-btn.layui-btn-sm .fa{ font-size: 14px !important;}
		.mr4{ margin-right: 4px;}
		.layui-form-item{ margin-bottom: 0px;}
		#check-item li{
			padding: 3px 5px;
			height: auto;
			line-height: 30px;
		}
    </style>
</head>
<body>
    <div style="padding: 20px;">
    	<ul id="check-item" style="list-style-type: none;">
    		<li>正在检查安装信息，请稍后...</li>
    	</ul>
    </div>

	<script src="__TMPL__/public/assets/js/jquery-1.10.2.min.js"></script>
	<script src="__STATIC__/js/layui/layui.all.js"></script>
	<script>
		var sign = {
				item:0,
				complete:1,
				canInstall:true,
				message:'信息验证中,请稍后',
			}; // 信号

		$('#check-item').append( '<li>' + sign.message + '</li>' );

		$(document).ready(function(){
			var url = "{:url('AppDevelop/testing')}";
			$.ajax({
				url:url,
				type:'POST',
				data:{
					store_id:"{$data.store_id}",
					name:"{$data.name}",
					version:"{$data.version}",
					menu_id:"{$data.menu_id}",
					status:"{$data.status}"
				},
				success:function( data ){
					showMessage( data );
					sign.item = sign.item + 1;
					parent.item = parent.item + 1;
				},
				error:function(){
					console.log(1000);
				}
			});
		})

		var showMessage = function( result ){ 
			let li = '';
			let icon  = "" ; 
			let color = '' ;
			$.each( result , function( index , value ){	
			sign.complete = sign.complete + 1;
			parent.complete = parent.complete + 1;
				// 警告信息 glyphicon glyphicon-info-sign
				// 200是错误信息 201 是警告信息   
				switch( value.code )
				{
					case 200 : 
						icon = '<span style="green;" class="glyphicon glyphicon-ok"></span>';

						color = 'color:#18BC9C;';

						sign.item = sign.item + 1;
						parent.item = parent.item + 1;

						break;
					case 201 :
						icon = '<span style="color:orange;" class="glyphicon glyphicon-info-sign"></span>' ;

						color = 'color:orange;';

						sign.canInstall = false;

						sign.item = sign.item + 1;
						parent.item = parent.item + 1;
						break;
					default:
						//错误信息
						icon = '<span style="color:red;" class="glyphicon glyphicon-remove"></span>' ;

						color = 'color:red';

						sign.canInstall = false;

						sign.message = value.item + ":" + value.msg;
					break;
				}
				li = '<li style="'+color+'">'+ value.item + ':' + value.msg +icon+'</li>';

				$('#check-item').append( li );
			});

			if(sign.canInstall == true){

				parent.installaa = true;
			}
		};

		var clock = setInterval(function(){	
			if( sign.item == sign.complete ){
				clearInterval( clock );
				if( sign.complete == sign.item ){

					$('#check-item').append( '<li>信息检查完成</li>' );
				}
			}
		},1000);



	</script>
</body>
</html>



